
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
  session_start();
if($_SESSION['username']!=null)
{
$title="Giới thiệu nhà hàng";


require '../layout/headeradmin.inc';

$title="";
$cate_id=0;
$images="";
$introtext="";
$fulltext="";
$chk=0;
$metakey="";
$create_by=1;
$modified_by=1;
$checkin=0;
$id=0;
$image="";
if(isset($_POST['luu_bv']))
{
    $id=$_POST['id'];
 $title=  trim($_POST['title']);
   
        $image=trim($_POST['Image']);
  
   $introtext=  trim(addslashes($_POST['introtext']));
   $fulltext= trim(addslashes($_POST['fulltext']));;

  
    $metakey= trim(addslashes($_POST['metakey']));
    $create_by=1;
    $modified_by=1;
    
    
    
     $images=addslashes($_POST['Image']);

     if(get_magic_quotes_gpc())
    {
        $title=  trim(addslashes($_POST['title']));
     

      
        $introtext=  trim(addslashes($_POST['introtext']));
       $fulltext=trim(addslashes($_POST['fulltext']));;
      
       
        $metakey= trim(mysqli_real_escape_string($_POST['metakey']));
   
    }
   //  $k->insertArticle($title,$introtext,$fulltext,$cate_id,$create_by,$modified_by,$chk,$images,$metakey);
   //  
   //  
  //  $k->insertArticle($id,$title,$introtext,$fulltext,$catid,$create_by,$modified_by,$images,$metakey,$active,$checkin);
    $db=  mysqli_connect("localhost", "root", "", "datashop");
     mysqli_set_charset($db, "utf8");
	 
	
	
	 $Active=1;
	 $checkin=1;
	 $modified_by=1;
	 $create_by=1;
 $created=date("Y-m-d");
  $modified=date("Y-m-d");
  $sql="UPDATE `present` SET `title`='$title', `fulltext`='$fulltext', `introtext`='$introtext'".
		", `created`=$created, `created_by`=$create_by, `modified`='$modified', `modified_by`=$modified_by, `metakey`='$metakey',`images`='$image' where `id`=1";
      
	   mysqli_query($db, $sql);
        
  header("Location:home.php");
}
 else {
    

?>
<!--<script src="../plugin/ckeditor_4.4.4_full/ckeditor/ckeditor.js" type="text/javascript"></script>-->

<script src="../scripts/jquery-1.5.1.js" type="text/javascript"></script>
<script src="../plugin/ckeditor/ckeditor.js" type="text/javascript"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../plugin/ckfinder/ckfinder.js" type="text/javascript"></script>
<script src="../plugin/ckeditor/adapters/jquery.js"></script>
<script type="text/javascript">
        function BrowseServer() {
            var finder = new CKFinder();
         //   finder.basePath = '../uploadimages/';
            finder.selectActionFunction = SetFileField;
            finder.popup();
        }
        function SetFileField(fileUrl) {
            document.getElementById('Image').value = fileUrl;
        }
    </script>
<script>
    $( document ).ready( function() {
	$( 'textarea#fulltext' ).ckeditor(function(){}, {
                        uiColor: '#14B8C4',language: 'vi'
                    } );
} );
</script>

<?php
	
	$db=$k->getContentPresentById();
	$row=mysqli_fetch_array($db);
	$img= $row['images'];
  $introtext=  $row['introtext'];
    $fulltext= $row['fulltext'];
	$checkin=$row['checkin'];
	$Active=$row['Active'];
	$cate_id=$row['catid'];


?>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data">
    <fieldset>
        <legend><text>Bài viết giới thiệu nhà hàng</text></legend>
        <table id="t-adduser">
            <tbody>
			<tr style="display:none;">
                    <td><label>Id</label></td>
                    <td><input type="text" id="id" name="id" value="1"></td>
                </tr>
                <tr>
                    <td><label>Tiêu đề</label></td>
                    <td><input type="text" id="title" name="title" value="<?php echo $row['title'];?>"></td>
                </tr>
                <tr>
                    <td><label>Metakey</label></td>
                    <td><input type="text" id="metakey" name="metakey" value="<?php echo $row['metakey'];?>"></td>
                </tr>
<!--                 <tr>
                    <td><label>ckeditor</label></td>
                    <td><textarea row="4" cols="100" class="ckeditor" name="eddd" ></textarea></td>
                </tr>-->
            
                 <tr>
                    <td><label>Ảnh đại diện</label></td>
<!--                    <td><input type="file" name="file" id="file"></td>-->
                    <td>
                        <input type="text" name="Image" id="Image" value="<?php echo $img;?>" />
    <input type="button" value="Chọn Ảnh ..." onclick="BrowseServer();"/>
                    </td>
                </tr>
                 <tr>
                    <td><label>Thông tin</label></td>
                    <td><textarea row="4" cols="100"  id="introtext" name="introtext"  ><?php echo $introtext;?></textarea></td>
                </tr>
                <tr>
                    <td><label>Nội dung</label></td>
                    <td> <textarea cols="80" id="fulltext" name="fulltext" rows="10"><?php echo $fulltext;?></textarea>
			
		
                        </td>   
		
                </tr>
              
                <tr>
                    <td colspan="2" style="text-align: center;" >
                        <div>
                            <input type="submit" name="luu_bv" value="Lưu lại" >
                            <input type="button" name="huy" value="Hủy" id="cancel" >
                        </div>
                    </td>
                </tr>
            </tbody>
            <tfoot>
              
   
            </tfoot>
        </table>
    </fieldset>
</form>



<?php
 }
require '../layout/footeradmin.inc';
}
else
{
	header('Location:index.php');
}
?>